You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 Security concerns
Sensitive information exposure: question_for_agent now logs both the question and the full conversation via debug_pii. Ensure debug/PII logging is disabled in production and sanitized as needed. Additionally, the UI stores full conversation messages in localStorage (selectedConversationData), which persists across sessions and could expose sensitive chat content on shared machines.
The code uses createClientMessage to preload chat history but it is neither imported nor provided via props, which will cause a reference error and break the chat UI initialization flow.
returntimeA-timeB;// Oldest first});constloadedMessages: any[]=[];sortedMessages.forEach((msg: any)=>{if(msg.role==="user"){// Create user messageconstuserMessage=createClientMessage(msg.content||"",{delay: 0,});loadedMessages.push(userMessage);}elseif(msg.role==="system"){// Create bot messageconstbotMessage=createChatBotMessage({content: msg.content||"",response_type: msg.response_type||"text",query_sources: msg.query_sources,answered_question: msg.answered_question,});loadedMessages.push(botMessage);}});// Set the loaded messages in the chat stateif(loadedMessages.length>0){setState((prev: any)=>({
...prev,messages: loadedMessages,}));}}catch(error){// Silently handle error parsing conversation data}}},[createChatBotMessage,createClientMessage,setState]);
PydanticOutputParser[RouterResponse](...) may raise a TypeError if the class is not subscriptable; the prior non-generic usage PydanticOutputParser(...) is the standard pattern. Also, the function is annotated to return str but returns a parsed object with .datasource, which mismatches the annotation.
def__init__(self, llm_model, db_conn: TigerGraphConnection):
self.llm=llm_modelself.db_conn=db_conndefroute_question(self, question: str, conversation: list[dict[str, str]] =None) ->str:
"""Route a question to the appropriate datasource. Args: question (str): The question to route. Returns: str: The datasource to use for the question. """LogWriter.info(f"request_id={req_id_cv.get()} ENTRY route_question with {question}")
v_types=self.db_conn.getVertexTypes()
e_types=self.db_conn.getEdgeTypes()
router_parser=PydanticOutputParser[RouterResponse](pydantic_object=RouterResponse)
prompt=PromptTemplate(
template=self.llm.route_response_prompt,
When SupportAI is disabled or the router selects vectorstore, the fallback route goes to history_lookup instead of the previous inquiry/function path. This may degrade answers by preferring history over vectorstore in unsupported configurations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Bug fix
Description
Route using 'history' when relevant
Generate answers from conversation context
Cache TokenCalculator via factory
UI loads and sorts chat history
Diagram Walkthrough
File Walkthrough
13 files
Switch to cached token calculator factoryAdd 'history' option to router promptIntroduce cached get_token_calculator factoryInclude conversation in agent inputs and logsUse cached token calculator in generatorAdd history lookup path and workflow wiringRoute with conversation context and typed parserReturn timestamps in conversation history payloadUse cached token calculator in retrieverRevamp conversation history: sort, expand, resumePrompt updates: score and select contextsPrompt updates: score and select contextsPrompt updates: score and select contexts1 files
Reduce verbosity by suppressing similarity logs1 files
Load/render past messages; refresh list on send1 files
Add rule to disallow trailing spaces